package com.tonggedata.dataapi.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;

public class PropertiesUtils {
    public Properties getProperties() throws IOException {
        Properties properties = new Properties();
        InputStream inStream=this.getClass().getResourceAsStream("druid.properties");//获取配置文件输入流
        try {
            properties.load(inStream);//载入输入流
            Enumeration enumeration=properties.propertyNames();//取得配置文件里所有的key值
            while(enumeration.hasMoreElements()){
                String key=(String) enumeration.nextElement();
                System.out.println("配置文件里的key值："+key+"=====>配置文件里的value值："+properties.getProperty(key));//输出key值
            }

        } catch (IOException e) {
            throw new IOException("配置文件读取失败");
        }
        return properties;
    }
}
